/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-11-26
 * Time: 0:24
 */
public class TestH18 {
        public String intToRoman(int num) {
            StringBuilder ans = new StringBuilder();
            String[] roman = {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};
            int[] arab = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
            int index = 0;
            while(num > 0) {
                int count = num / arab[index];
                while(count-- > 0) {
                    ans.append(roman[index]);
                }
                num = num % arab[index];
                index++;
            }
            return ans.toString();
        }
}
